<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class BaseController extends Controller
{
    protected $pagsize = 2;
    public function __construct()
    {
        $this->pagsize = config("app.pagsize",2);
    }
    public function upfile(Request $request){
//        dump($request);die;
        $pic = "uploads/noimg.jpg";
        $upName = $request->get("node","article");
        # 判断他是否上传图片
        if($request->hasFile("file")){
            $file = $request->file("file");
//            dump($file);
            $filename = $file->store($upName,"upfile");
            $pic = "/uploads/".$filename;
        }
        return ["pic"=>$pic];
    }
    # 删除图片处理
    public function deletePic(Request $request){
        $path = $request->get("path");
        $findepath = public_path($path);
        # 删除
        if(file_exists($findepath)){
            unlink($findepath);
        }
        return ["status" => 0,"msg" => "删除成功"];
    }
}
